<template>
  <div class="box3">
    <div class="box1">
      <h3>常用缴费</h3>
    </div>
    <div class="box">
      <div v-for="v in obj" :key="v.id">
        <div @click="fun(v.id)">
          <img :src="v.img" alt="" />
          <p>{{ v.text | sangedian }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    fun(e) {
      switch (e) {
        case 2:
          this.$router.push("./wuyefei");
          break;
      }
    },
  },
  data() {
    return {
      text: "常用缴费",
      obj: [
        { id: 1, img: "./img/life/cyjf1.png", text: "本地手机充值" },
        { id: 2, img: "./img/life/cyjf2.png", text: "物业费" },
        { id: 3, img: "./img/life/cyjf3.png", text: "固话话费" },
        { id: 4, img: "./img/life/cyjf4.png", text: "IC卡、联名卡充值" },
        { id: 5, img: "./img/life/cyjf5.png", text: "水费" },
        { id: 6, img: "./img/life/cyjf6.png", text: "电费" },
        { id: 7, img: "./img/life/cyjf7.png", text: "热力（暖气）" },
        { id: 8, img: "./img/life/cyjf8.png", text: "全部" },
      ],
    };
  },
  filters: {
    sangedian(val) {
      if (val.length > 4) {
        return val.substr(0, 4) + "...";
      } else {
        return val;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.box3 {
  width: 100%;
  > .box1 {
    width: 90%;
    margin: auto;
    > h3 {
      line-height: 0.6rem;
      font-size: 0.2rem;
      font-weight: 800;
    }
  }
  > .box {
    width: 90%;
    margin: auto;
    display: flex;
    height: 1rem;
    justify-content: space-between;
    flex-wrap: wrap;
    text-align: center;
    > div {
      width: 0.8rem;
      height: 1rem;
      > div {
        > img {
          width: 0.3rem;
        }
        > p {
          font-size: 0.14rem;
        }
      }
    }
  }
}
</style>